package com.pusilkom.logger;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

import com.pusilkom.uploader.AutodebetWorkerConfig;

/**
 * @name Debuger
 * @author Purwa
 * @desc Debug every action that should be debug.
 *
 */
public class Debuger {
	
	private AutodebetWorkerConfig conf;
	private boolean isRunDebug = false;	
    private DateFormat debugTimeFormat;
	
	public Debuger(AutodebetWorkerConfig config) {
		this.conf = config;
		debugTimeFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss.SSS");
		setRunDebug();
	}
	
	private void setRunDebug() {		
		String debug = conf.getParameter("debug");
		if(debug.equalsIgnoreCase("1")) {
			this.isRunDebug = true;
		}		
	}
	
	public void debug(String msg) {		
		Date date = new Date();
		if(isRunDebug)
			System.out.println(debugTimeFormat.format(date)+" : "+msg);
	}
}
